/**
 * 工程名: HelloMyFriend
 * 文件名: DeskTopActivity.java
 * 包名: com.stdroom.hellomyfriend.ui
 * 日期: 2013-5-22上午10:11:06
 * Copyright (c) 2013, 北京联龙博通 All Rights Reserved.
 *
*/

package com.stdroom.hellomyfriend.ui;

import com.stdroom.hellomyfriend.constants.View_Util;
import com.stdroom.hellomyfriend.view.AppCenter;
import com.stdroom.hellomyfriend.view.Chat;
import com.stdroom.hellomyfriend.view.Desktop;
import com.stdroom.hellomyfriend.view.Desktop.OnChangeViewListener;
import com.stdroom.hellomyfriend.view.Friends;
import com.stdroom.hellomyfriend.view.LocationView;
import com.stdroom.hellomyfriend.view.Message;
import com.stdroom.hellomyfriend.view.MessageResource;
import com.stdroom.hellomyfriend.view.NewsFeed;
import com.stdroom.hellomyfriend.view.PhoneContacts;
import com.stdroom.hellomyfriend.view.SearchView;
import com.stdroom.hellomyfriend.widget.FlipperLayout;
import com.stdroom.hellomyfriend.widget.FlipperLayout.OnOpenListener;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup.LayoutParams;

/**
 * 类名: DeskTopActivity <br/>
 * 功能: TODO 添加功能描述. <br/>
 * 日期: 2013-5-22 上午10:11:06 <br/>
 *
 * @author   lx
 * @version  	 
 */
public class DeskTopActivity extends Activity implements OnOpenListener{
	
	private FlipperLayout mRoot = null;
	private Desktop mDeskTop = null;
	private PhoneContacts mPhoneContacts = null;
	private MessageResource mMessageResource = null;
	private Friends mFriends = null;
	private Message mMessage = null;
	private NewsFeed mNewsFeed = null;
	private Chat mChat = null;
	private LocationView mLocationView = null;
	private SearchView mSearchView = null;
	private AppCenter mAppCenter = null;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mRoot = new FlipperLayout(DeskTopActivity.this);
		LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT,
				LayoutParams.FILL_PARENT);
		mRoot.setLayoutParams(params);
		
		mDeskTop = new Desktop(DeskTopActivity.this);
		mPhoneContacts = new PhoneContacts(DeskTopActivity.this);
		mMessageResource = new MessageResource(DeskTopActivity.this);
		mFriends = new Friends(DeskTopActivity.this);
		mMessage = new Message(DeskTopActivity.this);
		mNewsFeed = new NewsFeed(DeskTopActivity.this);
		mChat = new Chat(DeskTopActivity.this);
		mLocationView = new LocationView(DeskTopActivity.this);
		mSearchView = new SearchView(DeskTopActivity.this);
		mAppCenter = new AppCenter(DeskTopActivity.this);
		
		mRoot.addView(mDeskTop.getView(),params);
		mRoot.addView(mNewsFeed.getView(),params);
		
		setContentView(mRoot);
		setOnListener();
	}
	
	private void setOnListener(){
		mDeskTop.setOnChangeViewListener(new OnChangeViewListener(){
			@Override
			public void onChangeView(int arg0) {
				switch(arg0){
				case View_Util.Information:
					mRoot.close(mPhoneContacts.getView());
					break;
				case View_Util.NewsFeed:
					mRoot.close(mNewsFeed.getView());
					break;
				case View_Util.Message:
					mRoot.close(mMessage.getView());
					break;
				case View_Util.Chat:
					mRoot.close(mChat.getView());
					break;
				case View_Util.Friends:
					mRoot.close(mFriends.getView());
					break;
				case View_Util.Page:
					mRoot.close(mMessageResource.getView());
					break;
				case View_Util.Location:
					mRoot.close(mLocationView.getView());
					break;
				case View_Util.Search:
					mRoot.close(mSearchView.getView());
					break;
				case View_Util.Apps_Center:
					mRoot.close(mAppCenter.getView());
					break;
				default:
					mRoot.close(mAppCenter.getView());
					break;
				}
			
			}
			
		});
	}
	
	public void open() {
		if (mRoot.getScreenState() == FlipperLayout.SCREEN_STATE_CLOSE) {
			mRoot.open();
		}
	}

}

